# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=portaudio

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=19_20140130
pkgrel=1
pkgdesc="A free, cross-platform, open source, audio I/O library. (mingw-w64)"
arch=('any')
url="http://www.portaudio.com"
license=("custom")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
options=(!libtool strip !makeflags staticlibs)
source=("http://www.portaudio.com/archives/pa_stable_v$pkgver.tgz"
    mingw-w64-fix.patch
    mingw-w64-cmake-allow-cxx.patch)
md5sums=('7f220406902af9dca009668e198cbd23'
         '99da198098bd39e24333d6e4ab1bef4a'
         '9ae34b0d0dee106c6a90dfc744bf096c')

prepare() {
  cd ${srcdir}/${_realname}
  patch -p2 -i ${srcdir}/mingw-w64-fix.patch
  patch -p2 -i ${srcdir}/mingw-w64-cmake-allow-cxx.patch

  autoconf
}

build() {
  export lt_cv_deplibs_check_method='pass_all'
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  ${srcdir}/${_realname}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-shared \
    --enable-cxx \
    --with-dxdir=${MINGW_PREFIX}/${MINGW_CHOST} \
    --with-winapi=wmme,directx,wdmks
    #wasapi,
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="$pkgdir" install
}
